<template>
  <page-body>
    <view class="page">
      <view class="flex flex-wrap align-center justify-between benben-position-layout flex fans_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center fans_fd0_0' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
          <image class='fans_fd0_0_c0' mode="aspectFit" :src='STATIC_URL+"39.png"'></image>
        </view>
        <text class='fans_fd0_1'>{{type==1 ? '我的关注' : '我的粉丝'}}</text>
        <view class='flex flex-wrap align-center fans_fd0_0'>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---关注flex布局开始-->
      <view class="flex flex-direction align-stretch benben-flex-layout fans_flex_1">
        <template v-for='(item,key0) in dataList'>
          <view class='flex align-center fans_fd1_0' :key='key0' @tap.stop="goDetail(item)" data-type="navigateTo"
            :data-url="`/pages/grzx/userHome/userHome?aid=${item.user_id}`">
            <view class='flex flex-wrap align-center fans_fd1_0_c0'>
              <image class='fans_fd1_0_c0_c0' mode="aspectFill" :src='item.avatar'></image>
              <!--  <benben-message-num class='fans_fd1_0_c0_c1' size='24' color='#fff' background-color='red'>
              </benben-message-num> -->
            </view>
            <view class='flex flex-direction align-stretch flex-sub'>
              <view class='flex flex-direction flex-wrap align-stretch'>
                <text class='fans_fd1_0_c1_c0_c0'>{{item.nickname}}</text>
                <view class='flex flex-wrap align-center fans_fd1_0_c1_c0_c1'>
                  <text>{{item.company_name}}</text>
                  <text class='fans_fd1_0_c1_c0_c1_c1'>{{item.zhiye}}</text>
                </view>
                <!-- <view class='flex flex-wrap align-center'>
                  <text class='fans_fd1_0_c1_c0_c2_c0'>项目立项</text>
                </view> -->
              </view>
            </view>
            <view v-if="type==2">
              <button class='fans_fd1_0_c2' v-if="item.is_follow==1 " @tap.stop="CancelFollowFunc(item)">相互关注</button>
              <button class='fans_fd1_0_c2' v-else @tap.stop="CancelFollowFunc(item)">回关</button>
            </view>

            <button class='fans_fd1_0_c2' v-if="item.is_follow==1 && type==1"
              @tap.stop="CancelFollowFunc(item)">{{$t('取消关注')}}</button>
            <!--    <button class='fans_fd1_0_c2' v-if="item.is_follow==0" @tap.stop="CancelFollowFunc(item)">+关注</button>
            <button class='fans_fd1_0_c2' v-if="type==2 && item.is_follow==1 "
              @tap.stop="CancelFollowFunc(item)">回关</button> -->
          </view>
        </template>
        <fu-empty :pagingListLoadedAll="pagingListLoadedAll" :pagingListNoListData="pagingListNoListData"
          :listDataLength="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
      </view>

      <!---关注flex布局结束-->


    </view>
  </page-body>
</template>
<script>
  import pagingList from '@/common/mixin/paging_list.js';
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},
    mixins: [pagingList],

    data() {
      return {
        "minixPagingListsApi": "",
        "pageingListApiMethod": "",
        "allowOnloadGetList": false,
        "dataList": [],
        "dataMessage": [],
        "type": "1",
        "use_id": ""
      };
    },
    computed: {

    },
    watch: {},
    onLoad(options) {
      let {
        type
      } = options
      if (type !== undefined) this.type = type
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {
      this.getListFunc()
    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {
      this.getListFunc()
    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      goDetail(item) {
        let id = ''
        if (this.type == 1) {
          id = item.user_id
        } else {
          id = item.fans_id
        }
        uni.navigateTo({
          url: `/pages/grzx/userHome/userHome?aid=${id}`
        })
      },
      //取消关注
      async CancelFollowFunc(item) {
        //请求方法
        //数据验证
        let id = ''
        if (this.type == 1) {
          id = item.user_id
        } else {
          id = item.fans_id
        }
        let data664317b3cb108 = await this.$api.post(global.apiUrls.post66505b8b64564, {
          user_id: id,
        });

        if (data664317b3cb108.data.code != 1) {
          this.$message.info(data664317b3cb108.data.msg);
          return
        }
        let info664317b3cb108 = data664317b3cb108.data;
        item.is_follow == 0 ? item.is_follow = 1 : item.is_follow = 0

        this.getListFunc()
      },
      //用户管理-关注列表
      getListFunc() {
        this.minixPagingListsApi = global.apiUrls.post66505c8553f55;
        this.pageingListApiMethod = 'post';
        this.allowOnloadGetList = false;
        this.pagingListPostDataContent = {
          type: this.type
        }
        this.listData = [];
        this.dataList = this.listData;
        this.pagingListToggle();

      },
      pagingListPostData() {
        return this.pagingListPostDataContent
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: var(--benbenbgColor1);
    background-size: 100% auto;
  }

  .fans_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .fans_fd0_1 {
    color: #333333;
    font-size: 36rpx;
    font-weight: 500;
    line-height: 50rpx;
  }

  .fans_fd0_0_c0 {
    width: 20rpx;
    height: 36rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx 32rpx;
  }

  .fans_fd0_0 {
    width: 100rpx;
    height: 88rpx;
  }

  .fans_flex_1 {
    background: #fff;
    padding: 0rpx 24rpx 8rpx 24rpx;
    background-size: 100% auto !important;
  }

  .fans_fd1_0_c2 {
    background: var(--benbenbgColor1);
    font-size: 24rpx;
    color: var(--benbenFontColor2);
    width: 156rpx;
    height: 56rpx;
    line-height: 56rpx;
    background-size: 100% auto;
  }

  .fans_fd1_0_c1_c0_c2_c0 {
    border: 1px solid var(--benbenbdColor3);
    background: #FFFFFF;
    border-radius: 8rpx;
    font-size: 22rpx;
    padding: 6rpx 10rpx 6rpx 10rpx;
    color: var(--benbenFontColor6);
    margin: 0rpx 12rpx 0rpx 0rpx;
  }

  .fans_fd1_0_c1_c0_c1_c1 {
    color: var(--benbenFontColor2);
    margin: 0rpx 0rpx 0rpx 12rpx;
  }

  .fans_fd1_0_c1_c0_c1 {
    margin: 4rpx 0rpx 6rpx 0rpx;
    font-size: 24rpx;
  }

  .fans_fd1_0_c1_c0_c0 {
    color: #333;
    font-weight: 600;
  }

  .fans_fd1_0_c0_c1 {
    position: absolute;
    top: 0rpx;
    right: 20rpx;
  }

  .fans_fd1_0_c0_c0 {
    width: 120rpx;
    height: 120rpx;
    margin: 0rpx 24rpx 0rpx 0rpx;
    border-radius: 16rpx;
  }

  .fans_fd1_0_c0 {
    position: relative;
  }

  .fans_fd1_0 {
    border-bottom: 1px solid #eee;
    padding: 20rpx 0rpx 24rpx 0rpx;
  }
</style>
